package
{
	/**
	 *
	 *@author CrazyChen 
	 *2013-4-10
	 */	
	import com.greensock.TweenLite;
	
	import flash.display.Bitmap;
	import flash.display.Shape;
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	
	public class PlantPanel extends Sprite
	{
		[Embed(source="resource/地图/植物1.png")]
		public var plant1:Class;
		[Embed(source="resource/地图/植物2.png")]
		public var plant2:Class;	
		[Embed(source="resource/地图/植物3.png")]
		public var plant3:Class;
		[Embed(source="resource/地图/植物4.png")]
		public var plant4:Class;
		[Embed(source="resource/地图/植物5.png")]
		public var plant5:Class;
		[Embed(source="resource/地图/植物6.png")]
		public var plant6:Class;
		[Embed(source="resource/地图/植物7.png")]
		public var plant7:Class;
		[Embed(source="resource/地图/植物8.png")]
		public var plant8:Class;
		[Embed(source="resource/地图/植物9.png")]
		public var plant9:Class;
		[Embed(source="resource/地图/植物10.png")]
		public var plant10:Class;
		[Embed(source="resource/地图/植物11.png")]
		public var plant11:Class;
		[Embed(source="resource/地图/植物12.png")]
		public var plant12:Class;
		[Embed(source="resource/地图/植物13.png")]
		public var plant13:Class;
		[Embed(source="resource/地图/植物14.png")]
		public var plant14:Class;
		[Embed(source="resource/地图/植物15.png")]
		public var plant15:Class;
		[Embed(source="resource/地图/植物16.png")]
		public var plant16:Class;
		[Embed(source="resource/地图/植物17.png")]
		public var plant17:Class;
		[Embed(source="resource/地图/植物18.png")]
		public var plant18:Class;
		[Embed(source="resource/地图/植物19.png")]
		public var plant19:Class;
		[Embed(source="resource/地图/植物20.png")]
		public var plant20:Class;
		[Embed(source="resource/地图/植物21.png")]
		public var plant21:Class;
		[Embed(source="resource/地图/植物22.png")]
		public var plant22:Class;
		[Embed(source="resource/地图/植物23.png")]
		public var plant23:Class;
		[Embed(source="resource/地图/植物24.png")]
		public var plant24:Class;
		
		private var _selectPlant:Class;

		public function PlantPanel()
		{
			super();
			this.y = 510;
			initface();
			this.addEventListener(MouseEvent.MOUSE_DOWN,chousePlant);
		}
		
		protected function chousePlant(event:MouseEvent):void
		{
			var plant:PlantPanelItem = event.target as PlantPanelItem;
			if(plant){
				selectPlant = plant.cls;
			}
		}
		
		private function initface():void
		{
			var sp:Shape = new Shape();
			this.addChild(sp);
			sp.graphics.beginFill(0xffffff);
			sp.graphics.drawRect(0,0,40*24,40);
			sp.graphics.endFill();
			var pItem:PlantPanelItem;
			for(var i:int=1;i<=24;i++){
				var bmp:Bitmap = new this["plant"+i]();
				pItem = new PlantPanelItem();
				this.addChild(pItem);
				pItem.addChild(bmp);
				pItem.width = bmp.height = 40;
				pItem.x = (i-1)*40;
				pItem.cls = this["plant"+i];
			}
		}
		
		public function turnPage(event:MouseEvent):void
		{
			if(this.x == 0){
				TweenLite.to(this, 1, {x:TowerWarMap.instance.stage.stageWidth-this.width});
			}else{
				TweenLite.to(this, 1, {x:0});
			}
		}

		public function get selectPlant():Class
		{
			return _selectPlant;
		}

		public function set selectPlant(value:Class):void
		{
			_selectPlant = value;
			if(value){
				TowerWarMap.instance.showMouseTip();
			}
		}

	}
}